package conf

import (
	"fmt"
	"os"
	"path/filepath"
	// "strconv"
)

var GET map[string]map[string]string

func walk(dir string, f func(filename string, fi os.FileInfo, err error)) {
	path := dir
	filepath.Walk(path, func(filename string, fi os.FileInfo, err error) error { //遍历目录
		if err != nil { //忽略错误
			fmt.Println(err)
			return err
		}

		if !fi.IsDir() { // 忽略目录
			f(filename, fi, err)
		}
		return err
	})
}

func Update() {
	walk("./config", func(filename string, fi os.FileInfo, err error) {
		// fmt.Println(filename)
		conf := SetConfig(filename)
		list := conf.ReadList()
		// c := list[0]["config"]

		for _, j := range list {
			for x, y := range j {
				GET[x] = y
			}
		}
	})
}

func init() {
	GET = make(map[string]map[string]string)
	Update()
}
